package com.hmall.order.web;

import com.hmall.common.utils.UserContext;
import com.hmall.order.pojo.Order;
import com.hmall.order.pojo.RequestParams;
import com.hmall.order.service.IOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("order")
public class OrderController {

    @Autowired
    private IOrderService orderService;

    @GetMapping("/hi")
    public String hi() {
        return "hi";
    }


    @GetMapping("{id}")
    public Order queryOrderById(@PathVariable("id") Long orderId) {
        System.out.println("用户信息： "+UserContext.getUser());
        return orderService.getById(orderId);
    }

    // 提交订单
    @PostMapping
    public Long createOrder(@RequestBody RequestParams requestParams) {

        return orderService.createOrder(requestParams);
    }

}
